﻿using Newtonsoft.Json;
using Simple.Services;

namespace Simple.WebApi.Controllers.System;

/// <summary>
/// 违章原因分析
/// </summary>
[Route("QHSEAnalysisPage/[action]")]
[ApiController]
public class QHSEAnalysisPageController : ControllerBase
{
    private readonly AnalysisPageService _analysisPageService;


    public QHSEAnalysisPageController(AnalysisPageService analysisPageService)
    {
        _analysisPageService = analysisPageService;
    }

    /// <summary>
    /// 分析页：违章隐患总数、趋势
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEVadTotalAnalysis()
    {
        var res = await _analysisPageService.QHSEVadTotalAnalysisAsync();
        return Ok(JsonConvert.SerializeObject(res));
    }
    /// <summary>
    /// 分析页：违章级别
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEViolationTypeAnalysis()
    {
        var res = await _analysisPageService.QHSEViolationTypeAnalysisAsync();
        return Ok(res);
    }
    /// <summary>
    /// 分析页：隐患级别
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEDangerTypeAnalysis()
    {
        var res = await _analysisPageService.QHSEDangerTypeAnalysisAsync();
        return Ok(res);
    }
    /// <summary>
    /// 分析页：违章作业专业
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEViolationWorkSpecialtyAnalysis()
    {
        var res = await _analysisPageService.QHSEViolationWorkSpecialtyAnalysisAsync();
        return Ok(res);
    }
    /// <summary>
    /// 分析页：隐患作业专业
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEDangerWorkSpecialtyAnalysis()
    {
        var res = await _analysisPageService.QHSEDangerWorkSpecialtyAnalysisAsync();
        return Ok(res);
    }
    /// <summary>
    /// 分析页：二级单位隐患
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEDangerSecondaryUnitAnalysis()
    {
        var res = await _analysisPageService.QHSEDangerSecondaryUnitAnalysisAsync();
        return Ok(res);
    }
    /// <summary>
    /// 分析页：二级单位违章
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    [CustomAuthorize("hdv_qhse_data")]
    public async Task<IActionResult> QHSEViolationSecondaryUnitAnalysis()
    {
        var res = await _analysisPageService.QHSEViolationSecondaryUnitAnalysisAsync();
        return Ok(res);
    }
}
